package com.dong.service.impl;

import java.util.List;

import com.dong.dao.UserDao;
import com.dong.dao.impl.UserDaoImpl;
import com.dong.entity.UserEntity;
import com.dong.service.UserService;

public class UserServiceImpl implements UserService {
  
   private UserDao userDao=new UserDaoImpl();
	

	@Override
	public void delete(Long id) {
		userDao.delete(id);
		
	}

	@Override
	public void update(UserEntity userName) {
		userDao.update(userName);
		
	}

	@Override
	public List<UserEntity> listAll() {
		// TODO Auto-generated method stub
		return userDao.listAll();
	}

	@Override
	public UserEntity getById(Long id) {
		// TODO Auto-generated method stub
		return userDao.getById(id);
	}

	@Override
	public void addOrUpdate(UserEntity userName) {
		if(userName.getId()==null) {
			userDao.add(userName);
		}else {
			userDao.update(userName);
		}
		
	}

}
